'''
This is Karma Cat! This is my attempt at creating a simple IRC Bot
to implement a Karma system!

This is based off code from :
http://oreilly.com/pub/h/1968
http://www.osix.net/modules/article/?id=780

Version| 1.0 Alpha-3
Author| btreecat
URL: https://code.google.com/p/karma-cat/
REPO: hg clone https://karma-cat.googlecode.com/hg/ karma-cat
LICENSE: GPL3
'''

'''Imports'''
#import sys
#import socket
from Parser import Parser
from Server import Server
#import os



class karma_cat:

    def __init__(self):

        '''Basic Configuration Section begins here'''
        #This Dictionary is for the server config
        self.configDic = {'HOST': 'chat.freenode.net', 'PORT': 6667, 'NICK': 'Dr_Meowzers_a2', 'IDENT': 'karma_cat', 'REALNAME': 'Karma Cat', 'CHANNELINIT': '#btreecat' }

        #Pets Owner
        self.OWNER = 'btreecat'
        #Admins (cant send "RAW" commands)
        self.ADMINS = [self.OWNER, 'stanner', 'ackthet']
        #Lets make an instance of our Parser

        self.server = Server(self.configDic)
        self.server.connectToServer()
        self.parser = Parser(self.OWNER, self.ADMINS, self.server)
        self.__goTime__()


    def __goTime__(self):

        #print("Its Go Time Baby!")
        '''Main while loop of bot.'''

        '''How I need to re-write this method based on new design:
        1) This method will be used to drive the main loop of the
            application.
        2)Will not read lines directly
            a) all lines will be passed to the parser which will 
                determine if the message should be replied to
            
        '''
#        while 1:
#
#            line=self.server.getLine()
#            print(line)
#            #This will handle PRIVMSG commands
#            if ('PRIVMSG' in line):
#                message=Message(line)
#                self.parser.setMessage(message)
#
#            if (':die' in line):
#                if (self.OWNER + '!' in line[0]):
#                    print('Master commanded me to quit')
#                    self.aSocket.send(bytes('PRIVMSG ' + self.CHANNELINIT + " :" + self.OWNER + " quitting...\r\n", 'UTF-8'))
#                    self.aSocket.send(bytes('QUIT \r\n', 'UTF-8'))
#                    sys.exit(3)


'''
Now we actually need to run our class
'''
cat = karma_cat()

